<?php
// 获取评论列表
// header("content-type:text/html;charset=utf-8");
include_once("conn.php");

if(empty($_GET['name'])){
    $sql = "SELECT * FROM tb_remark_info 
    LEFT JOIN tb_user_info ON tb_remark_info.uid = tb_user_info.uid
    LEFT JOIN tb_goods_info ON tb_remark_info.g_id = tb_goods_info.g_id";
}else{
    $name = $_GET['name'];
    $sql = "SELECT * FROM tb_remark_info 
    LEFT JOIN tb_user_info ON tb_remark_info.uid = tb_user_info.uid
    LEFT JOIN tb_goods_info ON tb_remark_info.g_id = tb_goods_info.g_id
    WHERE tb_goods_info.g_name LIKE '%".$name."%'
    OR tb_goods_info.g_id LIKE '%".$name."%'";
}

$result = mysqli_query($conn,$sql);
if($result){
    if(mysqli_num_rows($result)>0){
        while($row = mysqli_fetch_assoc($result)){
            echo"
                <tr>
                    <th scope='row'>".$row['g_name']."</th>
                    <td>".$row['uname']."</td>
                    <td>".$row['content']."</td>
                    <td>".$row['r_date']."</td>
                </tr>";
        }
    }else{
        echo "<tr><td colspan='4'>未查询到评论信息</td></tr>";
    }
}else{
    echo "<tr><td colspan='4'>查询失败</td></tr>";
}


